import { uniqueId } from 'lodash'

function supplementPath(menu) {
    return menu.map(e => ({
        ...e,
        path: e.path || uniqueId('d2-menu-empty-'),
        ...e.children ? {
            children: supplementPath(e.children)
        } : {}
    }))
}

const root = 'suproot'

const menuHeadersuproot = [
    { path: '/index', title: '首页', icon: 'home' }
]

const menuAsidesuproot = [
    { path: '/index', title: '首页', icon: 'home' },
    { path: '/pageIndex', title: '可视化大屏', icon: 'laptop' },
    {
        title: '资源上传',
        icon: 'cloud-upload',
        children: [
            { path: '/video', title: '视频上传', icon: 'file-video-o ' },
            { path: '/monitoring', title: '监控调用', icon: 'video-camera' }
        ]
    },
    { path: '/audit', title: '申述审核', icon: 'check-square' },
    { path: '/Violations', title: '违规记录', icon: 'file-text' },
    { path: '/licensePlate', title: '车牌信息', icon: 'car' },
    { path: '/user', title: '用户管理', icon: 'user' }

]

const menuHeaderuser = [
    { path: '/index', title: '首页', icon: 'home' }
]

const menuAsideuser = [

    { path: '/index', title: '首页', icon: 'home' }
]

function getMenu(root, menu) {
    if (menu === 'menuAside') {
        if (root === 'suproot') {
            const menuAsides = menuAsidesuproot
            return menuAsides
        } else {
            const menuAsides = menuAsideuser
            return menuAsides
        }
    } else {
        if (root === 'suproot') {
            const menuHeaders = menuHeadersuproot
            return menuHeaders
        } else {
            const menuHeaders = menuHeaderuser
            return menuHeaders
        }
    }
}

export const menuAside = supplementPath(getMenu(root, 'menuAside'))
export const menuHeader = supplementPath(getMenu(root, 'menuHeader'))